package com.zqx.facade.facade;

import com.zqx.facade.abstractfacade.AbstractEncryptFacade;
import com.zqx.facade.childsystem.FileReader;
import com.zqx.facade.childsystem.FileWriter;
import com.zqx.facade.childsystem.NewCipherMachine;

/**
 * description: 外观类
 * @author zqx
 * @date 2018/09/04
 *
 */
public class NewEncryptFacade extends AbstractEncryptFacade {

    //维持对子系统对象的引用
    private FileReader fileReader;
    private NewCipherMachine newCipherMachine;
    private FileWriter fileWriter;

    public NewEncryptFacade() {
        fileReader = new FileReader();
        newCipherMachine = new NewCipherMachine();
        fileWriter = new FileWriter();
    }

    @Override
    public void fileEncrypt(String fileName, String fileNameDes) {
        String read = fileReader.read(fileName);
        String encrypt = newCipherMachine.encrypt(read);
        fileWriter.write(encrypt,fileNameDes);
    }
}
